package IO;

import java.io.File;
import java.io.IOException;

public class Demo01 {
    public static void main(String[] args) throws IOException {
//        绝对路径
        File f1 = new File("d:/test.txt");
        System.out.println(f1.getParent());
        System.out.println(f1.getName());
        System.out.println(f1.getAbsolutePath());
        System.out.println(f1.getCanonicalPath());

//        创建文件  这个也有可能出现异常
//        1.给出的路径非法
//        2.权限不足
        f1.createNewFile();

        System.out.println(f1.exists());
        System.out.println(f1.isFile());
        System.out.println(f1.isDirectory());
        System.out.println("=============================");
        File f2 = new File("./test.txt");
        System.out.println(f2.getParent());
        System.out.println(f2.getName());
        System.out.println(f2.getPath());
        System.out.println(f2.getAbsolutePath());
        System.out.println(f2.getCanonicalPath());


    }
}
